package com.platform.database.client;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.platform.database.contract.IDatabaseContract;
import com.platform.database.entity.DataBase;

/**
 * Locator
 * Created by flying on 16-9-7.
 */
public class PlatformDatabaseClientLocator {

    /**
     * application context file path
     */
    private final static String applicationContextPath = "spring/applicationContext.xml";

    /**
     * application context
     */
    private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(applicationContextPath);

    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }
    
    public static void main(String[] args) {
    	System.setProperty("production.mode", "ONLINE");
    	
    	IDatabaseContract dbContract = (IDatabaseContract) getApplicationContext().getBean("databaseContract");
    	DataBase db = dbContract.database();
    	System.out.println(db);
	}
}
